//
// Created by miaomiaole on 2023/5/21.
//

#include "sample_unique_prt.h"

#include <memory>

using namespace std;

void releas_unique_pointer() {
    auto up1 = std::make_unique<Sample>(3);
    auto up2 = std::make_unique<Sample>(42);

    //释放智能指针，需要手动删除
    auto prt = up2.release();

    up1.reset();

    // up2 is nullprt;
    if (up2) {
        std::cout << "up2 is not empty." << std::endl;
    }

    if (prt) {
        std::cout << "release prt is " << prt->content_ << std::endl;
    }


}

void releas_unique_ptr() {
    auto p = std::make_unique<Sample_2>();

    auto sample_1 = p->sample.get()->content_;


    std::cout << "sample content_1 = " << sample_1 << std::endl;
}

void smart_pointer() {
    shared_ptr<string> pNico(new string("nico"));
    shared_ptr<string> pJutta(new string("jutta"));


}

Sample &func_ref() {

    auto sample_prt = new Sample(10086);

    // return *sample_prt;
    Sample &&sample_ref = Sample(1008611);

    return static_cast<Sample &>(sample_ref);
}


void time_time() {
    time_t now = time(nullptr);

    cout << "UNIX Time : " << now << endl;
}
